package designPattern.command.macroCommand
{
	public class MacroCommand implements IMacroCommand
	{
		private var commandList:Array;
		public function MacroCommand()
		{
			commandList = [];
		}
		
		public function add(c:ICommand):void
		{
			commandList.push(c);
		}
		
		public function remove(c:ICommand):void
		{
			for(var i:int = 0; i < commandList.length; i++)
			{
				if(commandList[i] == c)
				{
					commandList.splice(i, 1);
					break;
				}
			}
		}
		
		public function execute():void
		{
			for(var i:int = 0; i < commandList.length; i++)
			{
				(commandList[i] as ICommand).execute();
			}
		}
	}
}